{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e101bcf9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "import os \n",
    "import numpy as np \n",
    "from shapely.geometry import Point, Polygon\n",
    "#from tqdm import tqdm, trange\n",
    "#import time \n",
    "import json "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7e22dc20",
   "metadata": {},
   "outputs": [],
   "source": [
    "vegetation_area=r'E:\\亚群系\\info.json'##植被区的xlsx\n",
    "vegetation_litte=r'E:\\亚群系\\xiaoqu.json'#植被小区的xlsx\n",
    "leixing_total=r'E:\\李东明（新）\\437b+431a_扭黄茅、孔颖草、芸香草草丛+芒草、野古草、金茅草丛\\csv'#新出的当前群系所有类型csv的文件夹\n",
    "excel_123=r'E:\\李东明（新）\\437b+431a_扭黄茅、孔颖草、芸香草草丛+芒草、野古草、金茅草丛\\格子图\\123.csv'#跟格子图跑出来的123\n",
    "save_path=r'E:\\csv'#生成表保存的路径\n",
    "qunxi_path=r'E:\\李东明（新）\\437b+431a_扭黄茅、孔颖草、芸香草草丛+芒草、野古草、金茅草丛'#跑的群系的总路径"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4fa99166",
   "metadata": {},
   "outputs": [],
   "source": [
    "bizhi_path=os.path.join(save_path,'比值分区.xlsx')\n",
    "liu_path=os.path.join(save_path,'六边形.xlsx')\n",
    "def changetypecsv(char):\n",
    "    if \"_\" not in char:\n",
    "        return char.replace(\".0.\",\".\").replace(\".\",\"-\")\n",
    "    else:\n",
    "        key = char.split(\"_\")[-1]\n",
    "        return key + \"-\" + char.split(\"_\")[0].split(\".\")[1] + \"-\" + char.split(\"_\")[0].split(\".\")[3]\n",
    "def max_count(test):\n",
    "    a = 0\n",
    "    max_str = 0\n",
    "    for i in test:\n",
    "        if test.count(i) > a:\n",
    "            a = test.count(i)\n",
    "            max_str = i\n",
    "    return max_str\n",
    "def paixu(L):\n",
    "    for i in range(len(L)):\n",
    "        for j in range(i+1,len(L)):\n",
    "            if L[i]>L[j]:\n",
    "                L[i],L[j]=L[j],L[i]\n",
    "    return L\n",
    "def concat_danyuange(df,c):\n",
    "    some = df[df['b'] == c]\n",
    "    some=some[['a','b','c','d','e']]\n",
    "    some_wentai=some.set_index(['c','e'])\n",
    "    return some_wentai\n",
    "def yawentai(df,i):\n",
    "    data_total=[]\n",
    "    try:\n",
    "        for w in range(6,1200,2):\n",
    "            data_litte=[]\n",
    "            if str(df.iloc[i,w])==str(np.NaN) or str(df.iloc[i,w])=='None':\n",
    "                break\n",
    "            else:\n",
    "                data_litte.append(df.iloc[i,w])\n",
    "                data_litte.append(df.iloc[i,w+1])\n",
    "                data_total.append(data_litte)\n",
    "    except:\n",
    "        print(df.iloc[i,0],'chaole')\n",
    "    return pd.DataFrame(data_total)\n",
    "def find_six(source_path):\n",
    "    path_total=[]\n",
    "    for root,dirs,files in os.walk(source_path): \n",
    "        for file in files:\n",
    "            filename_path=os.path.join(root,file)\n",
    "            #new_filename = rep(file)\n",
    "            try:\n",
    "                if filename_path.split('\\\\')[-2]=='六边形图' and '.csv' in filename_path.split('\\\\')[-1]:\n",
    "                    path_total.append(filename_path)\n",
    "            except:\n",
    "                pass \n",
    "    return path_total\n",
    "def panduan(df):\n",
    "    if df.iloc[0,2] > 0.6321:\n",
    "        quncong='稳态'\n",
    "    elif df.iloc[0,2] > 0.3679:\n",
    "        if df.iloc[1,2] > 0.3679:\n",
    "            quncong = \"双亚稳态\"\n",
    "        else:\n",
    "            quncong = \"单亚稳态\"\n",
    "    else:\n",
    "        quncong = \"混沌态\"\n",
    "    return quncong "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a302040c",
   "metadata": {},
   "outputs": [],
   "source": [
    "f2 = open(vegetation_area, 'r')\n",
    "info_data = json.load(f2)\n",
    "f3=open(vegetation_litte, 'r')\n",
    "xiaoqu_data = json.load(f3)\n",
    "for i in info_data.keys():\n",
    "    info_data[i]=Polygon(info_data[i])\n",
    "for j in xiaoqu_data.keys():\n",
    "    xiaoqu_data[j]=Polygon(xiaoqu_data[j])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "84c62fa1",
   "metadata": {},
   "outputs": [],
   "source": [
    "yaqunxi_total=[]\n",
    "for i in os.listdir(leixing_total):\n",
    "    if '.csv' in i:\n",
    "        yaqunxi=[]\n",
    "        #a=i.split('\\\\')[-1]\n",
    "        a=i.split('.csv')[0]\n",
    "        yaqunxi.append(changetypecsv(a))\n",
    "        daquyu=[]\n",
    "        xiaoquyu=[]\n",
    "        leixing_dandu=pd.read_csv(os.path.join(leixing_total,i))\n",
    "        asd=leixing_dandu[['XX','YY']]\n",
    "    #    print(asd)\n",
    "    #     asd.insert(loc=2, column='c', value=0)  # 在最后一列后，插入值全为3的c列\n",
    "    #     for u in range(len(asd)):\n",
    "    #     try:\n",
    "    #         kongbai=(asd.iloc[i,0],asd.iloc[i,1])\n",
    "    #         #print(str(kongbai))\n",
    "    #         asd.iloc[i,2]=str(kongbai)\n",
    "    #     except:\n",
    "    #         pass\n",
    "        for j in range(len(asd)):\n",
    "            point = Point(asd.iloc[j,0],asd.iloc[j,1])\n",
    "            for w in info_data.items():\n",
    "                #print(w[1])\n",
    "                if w[1].contains(point):\n",
    "                    daquyu.append(w[0])\n",
    "                    #print('成功')\n",
    "                    break\n",
    "            for w in xiaoqu_data.items():\n",
    "                if w[1].contains(point):\n",
    "                    xiaoquyu.append(w[0])\n",
    "                    #print('成功')\n",
    "                    break\n",
    "        try:\n",
    "            daquyu_most=max_count(daquyu)\n",
    "            xiaoquyu_most=max_count(xiaoquyu)\n",
    "            yaqunxi.append(daquyu_most)\n",
    "            yaqunxi.append(xiaoquyu_most)\n",
    "            yaqunxi_total.append(yaqunxi)\n",
    "        except:\n",
    "            print(a,'找不到')\n",
    "\n",
    "        #point = Point(asd.iloc[0,0],asd.iloc[0,1])\n",
    "zhibeiquyu_total=pd.DataFrame(yaqunxi_total)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "38022726",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <th>e</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"4\" valign=\"top\">503</th>\n",
       "      <th>503</th>\n",
       "      <td>5-1-1</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>503</th>\n",
       "      <td>5-1-2</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>503</th>\n",
       "      <td>5-1-3</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>503</th>\n",
       "      <td>5-1-4</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             a   b       d\n",
       "c   e                     \n",
       "503 503  5-1-1  稳态  100.0%\n",
       "    503  5-1-2  稳态  100.0%\n",
       "    503  5-1-3  稳态  100.0%\n",
       "    503  5-1-4  稳态  100.0%"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df=pd.read_csv(excel_123,encoding='gbk',names=list('abfghijklmnopqrstuvwxyz'))\n",
    "df.insert(loc=3, column='c', value=0)  # 在最后一列后，插入值全为3的c列\n",
    "df.insert(loc=3, column='d', value=0)  # 在最后一列后，插入值全为3的c列\n",
    "df.insert(loc=3, column='e', value=0)  # 在最后一列后，插入值全为3的c列\n",
    "for i in range(1,len(df)):\n",
    "    try:\n",
    "        if df.iloc[i,1]=='稳态':\n",
    "            df.iloc[i,3]=str(int(yawentai(df,i).iloc[0,0]))\n",
    "            df.iloc[i,4]=str(round((yawentai(df,i).iloc[0,1]),4)*100)+'%'\n",
    "            df.iloc[i,5]=str(int(yawentai(df,i).iloc[0,0]))\n",
    "        if df.iloc[i,1]=='双亚稳态':\n",
    "            df.iloc[i,3]=str(int(yawentai(df,i).iloc[0,0]))+','+str(int(yawentai(df,i).iloc[1,0]))\n",
    "            df.iloc[i,4]=str(round((yawentai(df,i).iloc[0,1]),4)*100)+'%'+','+str(round((yawentai(df,i).iloc[1,1]),4)*100)+'%'\n",
    "            df.iloc[i,5]=str(int(yawentai(df,i).iloc[0,0]))+','+str(int(yawentai(df,i).iloc[1,0]))\n",
    "        if df.iloc[i,1]=='单亚稳态':  \n",
    "            df.iloc[i,3]=str(int(yawentai(df,i).iloc[0,0]))\n",
    "            df.iloc[i,4]=str(round((yawentai(df,i).iloc[0,1]),4)*100)+'%'\n",
    "            df_lst1 = list(yawentai(df,i)[0])\n",
    "            df_lst1=[int(y) for y in df_lst1]\n",
    "            df_lst1.remove(int(yawentai(df,i).iloc[0,0]))\n",
    "            df_lst1=paixu(df_lst1)\n",
    "            df_lst1.append(int(yawentai(df,i).iloc[0,0]))\n",
    "            df.iloc[i,5]=str(df_lst1)\n",
    "        if df.iloc[i,1]=='混沌态':\n",
    "            df.iloc[i,3]=str(int(yawentai(df,i).iloc[0,0]))\n",
    "            df.iloc[i,4]=str(round((yawentai(df,i).iloc[0,1]),4)*100)+'%'\n",
    "            df_lst1 = list(yawentai(df,i)[0])\n",
    "            df_lst1=[int(y) for y in df_lst1]\n",
    "            df_lst1=paixu(df_lst1)\n",
    "            df.iloc[i,5]=str(df_lst1)\n",
    "    except:\n",
    "        print(df.iloc[i,0])\n",
    "hebing=pd.concat([concat_danyuange(df,'混沌态'),concat_danyuange(df,'稳态'),concat_danyuange(df,'单亚稳态'),concat_danyuange(df,'双亚稳态')], axis=0)\n",
    "hebing "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "519979a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>c</th>\n",
       "      <th>e</th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>503</td>\n",
       "      <td>503</td>\n",
       "      <td>5-1-1</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>503</td>\n",
       "      <td>503</td>\n",
       "      <td>5-1-2</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>503</td>\n",
       "      <td>503</td>\n",
       "      <td>5-1-3</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>503</td>\n",
       "      <td>503</td>\n",
       "      <td>5-1-4</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     c    e      a   b       d\n",
       "0  503  503  5-1-1  稳态  100.0%\n",
       "1  503  503  5-1-2  稳态  100.0%\n",
       "2  503  503  5-1-3  稳态  100.0%\n",
       "3  503  503  5-1-4  稳态  100.0%"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "for i in range(len(hebing)):\n",
    "    aoye=hebing.iloc[i,2]\n",
    "    if len(aoye)>6 and ',' not in aoye:\n",
    "        hebing.iloc[i,2]=aoye[0:5]+'%'\n",
    "    elif len(aoye)>6 and ',' in aoye:\n",
    "        aoye_list1=aoye.split(',')[0]\n",
    "        aoye_list2=aoye.split(',')[1]\n",
    "        hebing.iloc[i,2]=aoye_list1[0:5]+'%'+','+aoye_list2[0:5]+'%'\n",
    "hebing=hebing.reset_index() \n",
    "hebing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "6afb3e5e",
   "metadata": {},
   "outputs": [],
   "source": [
    "wanquan=pd.merge(hebing,zhibeiquyu_total,how='left',left_on='a',right_on=0)\n",
    "wanquan_1=wanquan[['e','c',1,2,'a','b','d']]\n",
    "wanquan_1.columns=['亚群系（主）' ,'亚群系（全）','群丛组','亚群丛组','群丛','群丛状态','占比']\n",
    "wanquan_1.to_excel(bizhi_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "69faa7e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "###############################跑六边形的#############################"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9df2b829",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5-1-3 chaole\n",
      "5-1-3 chaole\n",
      "5-1-3 chaole\n",
      "5-1-3 chaole\n",
      "5-1-3 chaole\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>c</th>\n",
       "      <th>e</th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6f</td>\n",
       "      <td>6f</td>\n",
       "      <td>5-1-1</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6f</td>\n",
       "      <td>6f</td>\n",
       "      <td>5-1-2</td>\n",
       "      <td>稳态</td>\n",
       "      <td>99.81%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6f</td>\n",
       "      <td>6f</td>\n",
       "      <td>5-1-4</td>\n",
       "      <td>稳态</td>\n",
       "      <td>100.0%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>['6f', '6f-3', '6f-4', '6g', '6g-6', '6g-1']</td>\n",
       "      <td>6g-1</td>\n",
       "      <td>5-1-3</td>\n",
       "      <td>单亚稳态</td>\n",
       "      <td>37.58%</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                              c     e      a     b       d\n",
       "0                                            6f    6f  5-1-1    稳态  100.0%\n",
       "1                                            6f    6f  5-1-2    稳态  99.81%\n",
       "2                                            6f    6f  5-1-4    稳态  100.0%\n",
       "3  ['6f', '6f-3', '6f-4', '6g', '6g-6', '6g-1']  6g-1  5-1-3  单亚稳态  37.58%"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "liubianxing_total=[]\n",
    "for i in find_six(qunxi_path):\n",
    "    df=pd.read_csv(i,encoding='gbk')\n",
    "    hexin=[]\n",
    "    df.sort_values(\"点数\",inplace=True,ascending=False)\n",
    "    #path=r'E:\\\\李东明（新）\\\\437a_扭黄茅、龙须草、白茅草丛\\\\六边形图\\\\3.4-1-3.csv'\n",
    "    csv_name=i.split('\\\\')[-1]\n",
    "    csv_name=csv_name.split('.csv')[0]\n",
    "    ########改赵艺的##############\n",
    "    \n",
    "    if '统计' in csv_name:\n",
    "        csv_name=csv_name.split('统计')[0]\n",
    "    ###########################\n",
    "    hexin.append(csv_name)\n",
    "    hexin.append(panduan(df))\n",
    "    hexin.append(df['点数'].sum())\n",
    "    for u in range(len(df)):\n",
    "        hexin.append(df.iloc[u,0])\n",
    "        hexin.append(round(float(df.iloc[u,2]),4))\n",
    "    liubianxing_total.append(hexin)\n",
    "df=pd.DataFrame(liubianxing_total)\n",
    "df.rename(columns={0:'a',1:'b'},inplace=True) \n",
    "df.insert(loc=3, column='c', value=0)  # 在最后一列后，插入值全为3的c列\n",
    "df.insert(loc=3, column='d', value=0)  # 在最后一列后，插入值全为3的c列\n",
    "df.insert(loc=3, column='e', value=0)  # 在最后一列后，插入值全为3的c列\n",
    "for i in range(0,len(df)):\n",
    "    try:\n",
    "        if df.iloc[i,1]=='稳态':\n",
    "            df.iloc[i,3]=str(yawentai(df,i).iloc[0,0])\n",
    "            df.iloc[i,4]=str(round((yawentai(df,i).iloc[0,1]),4)*100)+'%'\n",
    "            df.iloc[i,5]=str(yawentai(df,i).iloc[0,0])\n",
    "        if df.iloc[i,1]=='双亚稳态':\n",
    "            df.iloc[i,3]=str(yawentai(df,i).iloc[0,0])+','+str(yawentai(df,i).iloc[1,0])\n",
    "            df.iloc[i,4]=str(round((yawentai(df,i).iloc[0,1]),4)*100)+'%'+','+str(round((yawentai(df,i).iloc[1,1]),4)*100)+'%'\n",
    "            df.iloc[i,5]=str(yawentai(df,i).iloc[0,0])+','+str(yawentai(df,i).iloc[1,0])\n",
    "        if df.iloc[i,1]=='单亚稳态':  \n",
    "            df.iloc[i,3]=str(yawentai(df,i).iloc[0,0])\n",
    "            df.iloc[i,4]=str(round((yawentai(df,i).iloc[0,1]),4)*100)+'%'\n",
    "            df_lst1 = list(yawentai(df,i)[0])\n",
    "            df_lst1=[y for y in df_lst1]\n",
    "            df_lst1.remove(yawentai(df,i).iloc[0,0])\n",
    "            df_lst1=paixu(df_lst1)\n",
    "            df_lst1.append(yawentai(df,i).iloc[0,0])\n",
    "            df.iloc[i,5]=str(df_lst1)\n",
    "        if df.iloc[i,1]=='混沌态':\n",
    "            #print(df.iloc[i,3])\n",
    "            df.iloc[i,3]=str(yawentai(df,i).iloc[0,0])\n",
    "            df.iloc[i,4]=str(round((yawentai(df,i).iloc[0,1]),4)*100)+'%'\n",
    "            df_lst1 = list(yawentai(df,i)[0])\n",
    "            df_lst1=[y for y in df_lst1]\n",
    "            df_lst1=paixu(df_lst1)\n",
    "            df.iloc[i,5]=str(df_lst1)\n",
    "    except:\n",
    "        print(df.iloc[i,0],'跑失败了！！！')\n",
    "hebing=pd.concat([concat_danyuange(df,'混沌态'),concat_danyuange(df,'稳态'),concat_danyuange(df,'单亚稳态'),concat_danyuange(df,'双亚稳态')], axis=0)\n",
    "for i in range(len(hebing)):\n",
    "    aoye=hebing.iloc[i,2]\n",
    "    if len(aoye)>6 and ',' not in aoye:\n",
    "        hebing.iloc[i,2]=aoye[0:5]+'%'\n",
    "    elif len(aoye)>6 and ',' in aoye:\n",
    "        aoye_list1=aoye.split(',')[0]\n",
    "        aoye_list2=aoye.split(',')[1]\n",
    "        hebing.iloc[i,2]=aoye_list1[0:5]+'%'+','+aoye_list2[0:5]+'%'\n",
    "hebing=hebing.reset_index() \n",
    "hebing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "72fbe595",
   "metadata": {},
   "outputs": [],
   "source": [
    "wanquan=pd.merge(hebing,zhibeiquyu_total,how='left',left_on='a',right_on=0)\n",
    "wanquan_1=wanquan[['e','c',1,2,'a','b','d']]\n",
    "wanquan_1.columns=['亚群系（主）' ,'亚群系（全）','群丛组','亚群丛组','群丛','群丛状态','占比']\n",
    "wanquan_1.to_excel(liu_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "52b51f95",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
